package com.liu.susu.controller.asny.asny2;

import com.liu.susu.thread.task.async.async2.service.AsyncTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.time.LocalDateTime;

/**
 * @FileName AsyncTaskController3
 * @Description
 * @Author susu
 * @date 2022-03-09
 **/
@Controller
@RequestMapping
@Slf4j
public class AsyncTaskController3 {

    @Autowired
    private AsyncTaskService asyncTaskService;

    @ResponseBody
    @RequestMapping("/async3")
    public String doMyAllTask() {

        log.info("begin doMyAllTask()...");

        long currentTimeMillis = System.currentTimeMillis();
        asyncTaskService.doMyTask1();
        asyncTaskService.doMyTask2();
        asyncTaskService.doMyTask3();
        long currentTimeMillis1 = System.currentTimeMillis();

        log.info("end doMyAllTask()-->doMyAllTask任务总耗时:"+(currentTimeMillis1-currentTimeMillis)+"ms");

        return "ok";//异步响应
    }


}
